package com.ylsk.check.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ylsk.common.annotation.Log;
import com.ylsk.common.core.controller.BaseController;
import com.ylsk.common.core.domain.AjaxResult;
import com.ylsk.common.enums.BusinessType;
import com.ylsk.check.domain.CheckItemRecord;
import com.ylsk.check.service.ICheckItemRecordService;
import com.ylsk.common.utils.poi.ExcelUtil;
import com.ylsk.common.core.page.TableDataInfo;

/**
 * 施工检查项记录Controller
 * 
 * @author yangsy
 * @date 2023-12-18
 */
@RestController
@RequestMapping("/check/checkItemRecord")
public class CheckItemRecordController extends BaseController
{
    @Autowired
    private ICheckItemRecordService checkItemRecordService;

    /**
     * 查询施工检查项记录列表
     */
    @PreAuthorize("@ss.hasPermi('check:checkItemRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckItemRecord checkItemRecord)
    {
        startPage();
        List<CheckItemRecord> list = checkItemRecordService.selectCheckItemRecordList(checkItemRecord);
        return getDataTable(list);
    }

    /**
     * 导出施工检查项记录列表
     */
    @PreAuthorize("@ss.hasPermi('check:checkItemRecord:export')")
    @Log(title = "施工检查项记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckItemRecord checkItemRecord)
    {
        List<CheckItemRecord> list = checkItemRecordService.selectCheckItemRecordList(checkItemRecord);
        ExcelUtil<CheckItemRecord> util = new ExcelUtil<CheckItemRecord>(CheckItemRecord.class);
        util.exportExcel(response, list, "施工检查项记录数据");
    }

    /**
     * 获取施工检查项记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:checkItemRecord:query')")
    @GetMapping(value = "/{checkItemRecordId}")
    public AjaxResult getInfo(@PathVariable("checkItemRecordId") Long checkItemRecordId)
    {
        return success(checkItemRecordService.selectCheckItemRecordByCheckItemRecordId(checkItemRecordId));
    }

    /**
     * 新增施工检查项记录
     */
    @PreAuthorize("@ss.hasPermi('check:checkItemRecord:add')")
    @Log(title = "施工检查项记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckItemRecord checkItemRecord)
    {
        return toAjax(checkItemRecordService.insertCheckItemRecord(checkItemRecord));
    }

    /**
     * 修改施工检查项记录
     */
    @PreAuthorize("@ss.hasPermi('check:checkItemRecord:edit')")
    @Log(title = "施工检查项记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheckItemRecord checkItemRecord)
    {
        return toAjax(checkItemRecordService.updateCheckItemRecord(checkItemRecord));
    }

    /**
     * 删除施工检查项记录
     */
    @PreAuthorize("@ss.hasPermi('check:checkItemRecord:remove')")
    @Log(title = "施工检查项记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkItemRecordIds}")
    public AjaxResult remove(@PathVariable Long[] checkItemRecordIds)
    {
        return toAjax(checkItemRecordService.deleteCheckItemRecordByCheckItemRecordIds(checkItemRecordIds));
    }
}
